﻿
@{
    ViewBag.Title = "Workflow";
}

<h2>Workflow</h2>

<div id="table_div"></div>

@*<table class="table">
    <thead>
        <tr>
            <th></th>
        </tr>
    </thead>
</table>*@

<ol>
    <li>Rule 1
        <ol type="I">
            <li>
                Condition
                <ol type="i">
                    <li>status of form is "submitted"</li>
                </ol>
            </li>
            <li>
                Action
                <ol type="i">
                    <li>email "account managers"</li>
                    <li>change status to "pending account manager"</li>
                </ol>
            </li>
        </ol>
    </li>


    <li>
        Rule 2
        <ol type="I">
            <li>
                Condition
                <ol type="i">
                    <li>status of form is "pending account manager"</li>
                    <li>form is approve by account manager</li>
                </ol>
            </li>
            <li>
                Action
                <ol type="i">
                    <li>email "security managers"</li>
                    <li>change status to "pending security manager"</li>
                </ol>
            </li>
        </ol>
    </li>


    <li>
        Rule 3
        <ol type="I">
            <li>
                Condition
                <ol type="i">
                    <li>status of form is "pending account manager"</li>
                    <li>form require approval from all account manager</li>
                </ol>
            </li>
            <li>
                Action
                <ol type="i">
                    <li>email "security managers"</li>
                    <li>change status to "pending security manager"</li>
                </ol>
            </li>
        </ol>
    </li>

    <li>
        Rule 4
        <ol type="I">
            <li>
                Condition
                <ol type="i">
                    <li>status of form is "pending security manager"</li>
                    <li>form has a approve/reject status</li>
                </ol>
            </li>
            <li>
                Action
                <ol type="i">
                    <li>email "security managers"</li>
                    <li>change status to "pending security manager"</li>
                </ol>
            </li>
        </ol>
    </li>


    <li>
        Rule 5
        <ol type="I">
            <li>
                Condition
                <ol type="i">
                    <li>status of form is "pending security manager"</li>
                    <li>form require approval from all security manager</li>
                </ol>
            </li>
            <li>
                Action
                <ol type="i">
                    <li>email "tenant"</li>
                    <li>change status to "approved"</li>
                </ol>
            </li>
        </ol>
    </li>

    <li>
        Rule 6
        <ol type="I">
            <li>
                Condition
                <ol type="i">
                    <li>status of form is "pending security manager"</li>
                    <li>form has a rejection from a security manager</li>
                </ol>
            </li>
            <li>
                Action
                <ol type="i">
                    <li>email "tenant"</li>
                    <li>change status to "rejected"</li>
                </ol>
            </li>
        </ol>
    </li>
    
    @*<li>When status of form is "submitted":
        <ol type="i">
            <li>email "account managers"</li>
            <li>wait for one/all account manager to approve/reject the tenant access form</li>
            <li>change status to "pending account manager"</li>
        </ol>
    </li>


    <li>When status of form is "pending account manager":
        <ol type="i">
            
            <li>change status to "pending account manager"</li>
        </ol>
    </li>*@

    
</ol>

    

@section scripts {
    <script type="text/javascript" src="~/Scripts/underscore.js"></script>
    <script type="text/javascript" src="~/Scripts/statechart.js"></script>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
        google.charts.load('current', { 'packages': ['table'] });
        google.charts.setOnLoadCallback(drawTable);

        function drawTable() {
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Condition');
            data.addColumn('number', 'Salary');
            data.addColumn('boolean', 'Full Time Employee');
            data.addRows([
              ['entry',     { v: 10000, f: '$10,000'    }, true],
              ['state 1',   { v: 8000,  f: '$8,000'     }, false],
              ['Alice', { v: 12500, f: '$12,500'    }, true],
              ['Bob', { v: 7000, f: '$7,000' }, true],
              ['exit', { v: 7000, f: '$7,000' }, true]
            ]);

            var table = new google.visualization.Table(document.getElementById('table_div'));

            table.draw(data, { showRowNumber: true, width: '100%', height: '100%' });
        }

        (function ($) {
            var lightSwitch = _.extend({

                initialState: "Out",
                states: {
                    'Out': {
                        'on': { target: 'On' },
                        'out': { target: 'Out' }
                    },
                    'On': {
                        'on': { target: 'On' },
                        'out': { target: 'Out' }
                    }
                }

            }, Statechart);

            // Initialize the state machine and make the initial transition (to the `Out` state).
            lightSwitch.run();

            // Dispatch the `on` event to the machine which causes it to transit to the `On` state.
            lightSwitch.dispatch('on');
        }(jQuery));
    </script>
    }